﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VIP.Manager;

public class CommandManager : VIPMonoSingleton<CommandManager>
{

    /// <summary>
    /// 管理命令
    /// </summary>
    private Stack<BaseCommand> commandStack = new Stack<BaseCommand>();

    /// <summary>
    /// 增加命令
    /// </summary>
    /// <param name="baseCommand"></param>
    public void AddCommand(BaseCommand command)
    {
        command.Execute();
        commandStack.Push(command);
    }

    /// <summary>
    /// 移除命令 并且撤销一步操作
    /// </summary>
    public void RemoveCommand()
    {
        if (commandStack.Count > 0)
        {
            BaseCommand baseCommand = commandStack.Pop();
            baseCommand.Revoke();
        }
    }

}

